package Hibernate.dao;

import java.util.ArrayList;
import java.util.HashMap;

import net.sf.json.JSONObject;

/**
 * FinalScore entity. @author MyEclipse Persistence Tools
 */

public class FinalScore implements java.io.Serializable {

	// Fields

	private String userId;
	private String examId;
	private Double firstScore;
	private Double finalScore;

	// Constructors

	/** default constructor */
	public FinalScore() {
	}

	/** minimal constructor */
	public FinalScore(String userId, String examId) {
		this.userId = userId;
		this.examId = examId;
	}

	/** full constructor */
	public FinalScore(String userId, String examId, Double firstScore,
			Double finalScore) {
		this.userId = userId;
		this.examId = examId;
		this.firstScore = firstScore;
		this.finalScore = finalScore;
	}

	// Property accessors

	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getExamId() {
		return this.examId;
	}

	public void setExamId(String examId) {
		this.examId = examId;
	}

	public Double getFirstScore() {
		return this.firstScore;
	}

	public void setFirstScore(Double firstScore) {
		this.firstScore = firstScore;
	}

	public Double getFinalScore() {
		return this.finalScore;
	}

	public void setFinalScore(Double finalScore) {
		this.finalScore = finalScore;
	}

	@Override
	public String toString() {
		return "{userId:'" + userId + "', examId:'" + examId
				+ "', firstScore:'" + firstScore + "', finalScore:'"
				+ finalScore + "'}";
	}

	//输出excel
	public ArrayList<String> getInfo(String[] list){
		JSONObject jexamieeInfo = JSONObject.fromObject(this.toString());
		ArrayList<String> array = new ArrayList<String>();
		for(int i=0;i<list.length;i++){
			array.add(jexamieeInfo.getString(list[i]));
		}
		return array;
	}
	
	//输入excel
	public void setInfo (HashMap<String,String> userInfo){
		if(userInfo.containsKey("userId")){
			this.setUserId(userInfo.get("userId"));
		}
		if(userInfo.containsKey("examId")){
			this.setExamId(userInfo.get("examId"));
		}
		if(userInfo.containsKey("firstScore")){
			this.setFirstScore(Double.valueOf(userInfo.get("firstScore")));
		}
		if(userInfo.containsKey("finalScore")){
			this.setFinalScore(Double.valueOf(userInfo.get("finalScore")));
		}
	}
}